package com.example.lte.api;

import io.swagger.annotations.Api;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author lzh
 * @date 2020/10/22 - 14:39
 */
@RestController
@Api(tags = "测试模块")
public class TestApi {

    @InitBinder
    public void initBinder(ServletRequestDataBinder bin) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        CustomDateEditor cust = new CustomDateEditor(sdf, true);
        bin.registerCustomEditor(Date.class, cust);
    }

    @GetMapping("/ta1")
    public Date ta1(Date sendTime) {
        System.out.println(sendTime);
        return sendTime;
    }

    @GetMapping("/ta2")
    public String te() {
        return "test!12";
    }

}
